<!DOCTYPE HTML>
<html lang="en">
<head>
<title>Goto - Syntax &amp; Usage | AutoHotkey</title>
<meta name="description" content="The Goto statement jumps to the specified label and continues execution." />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>Goto</h1>

<p>Jumps to the specified label and continues execution.</p>

<pre class="Syntax"><span class="func">Goto</span>, Label</pre>
<h2>Parameters</h2>
<dl>

  <dt>Label</dt>
  <dd><p>The name of the <a href="../misc/Labels.htm">label</a> to which to jump.</p></dd>

</dl>

<h2>Remarks</h2>
<p>When using a dynamic label such as %MyLabel%, an error dialog will be displayed if the label does not exist. To avoid this, call <a href="IsLabel.htm">IsLabel()</a> beforehand. For example:</p>
<pre>if IsLabel(VarContainingLabelName)
    Goto %VarContainingLabelName%</pre>
<p>The use of Goto is discouraged because it generally makes scripts less readable and harder to maintain. Consider using <a href="Else.htm">Else</a>, <a href="Block.htm">Blocks</a>, <a href="Break.htm">Break</a>, and <a href="Continue.htm">Continue</a> as substitutes for Goto.</p>
<h2>Related</h2>
<p><a href="Gosub.htm">Gosub</a>, <a href="Return.htm">Return</a>, <a href="IsLabel.htm">IsLabel()</a>, <a href="Else.htm">Else</a>, <a href="Block.htm">Blocks</a>, <a href="Break.htm">Break</a>, <a href="Continue.htm">Continue</a></p>
<h2>Examples</h2>
<div class="ex" id="ExBasic">
<p><a href="#ExBasic">#1</a></p>
<pre>Goto, MyLabel
<em>; ...</em>
MyLabel:
Sleep, 100
<em>; ...</em></pre>
</div>

</body>
</html>
